/**
 * The SelectAllAction, when performed, selects all Shapes in the Drawing.
 * 
 * @author Giuseppe Mendola (giuseppe.mendola@usi.ch);Gregory Banfi (gregory.banfi@usi.ch);
 */

package ch.usi.inf.pf2.gui;

import javax.swing.AbstractAction;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;

import ch.usi.inf.pf2.Component;

public final class SelectAllAction extends AbstractAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final Model model;

	public SelectAllAction(final Model model) {
		this.model = model;
		putValue(NAME, "Select all");
		final ImageIcon icon = new ImageIcon(getClass().getResource(
				"shape_group.png"));
		putValue(SMALL_ICON, icon);
		putValue(SHORT_DESCRIPTION, "Select all components");
	}

	@Override
	public void actionPerformed(final ActionEvent ev) {
		Model.getSelection().clear();
		for (final Component component : Model.getDrawing()) {
			
			Model.getSelection().add(component);
			
		}
	}
}
